package com.example.web;

import com.example.component.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by riven on 12/19/16.
 */
@Controller
public class UserController {

    @RequestMapping(path = "/",method = RequestMethod.GET)
    public List<User> list(){
        List<User> list = new ArrayList<>();
        for (int i=0;i<10;i++){
            User user = new User();
            user.setId(Long.parseLong(i+""));
            user.setName("riven"+i);
            list.add(user);
        }
        return list;
    }

    @RequestMapping(path = "/index",method = RequestMethod.GET)
    public String index(ModelMap mv){
        mv.put("message","hello world");
        return "index";
    }
}
